#include "Frame/publisher.hpp"
#include "Frame/listener.hpp"
#include "log.h"

void Publisher::AddListener(Listener *p_listener)
{
	Log("Add Listener:" + p_listener->GetName() );
	m_listenerList.push_back(p_listener);
}

void Publisher::DeleteListener(Listener *p_listener)
{
	ListenerList_C_iterator it = m_listenerList.begin();
	for (; it != m_listenerList.end(); it++)
	{
		string name = (*it)->GetName();
		if (name.compare(p_listener->GetName()) == 0)
		{
			//找到了删除。
		}
	}
}

void Publisher::Notify(Image& image)
{
	ListenerList_C_iterator it = m_listenerList.begin();
	for (; it != m_listenerList.end(); it ++)
	{
		(*it)->Update(image);
	}
}
/*
void Publisher::Notify(Model* model)
{
	ListenerList_C_iterator it = m_listenerList.begin();
	for (; it != m_listenerList.end(); it ++)
	{
		(*it)->Update(model);
	}
}
*/
void Publisher::DoEvents(int s) // GUI 
{
	ListenerList_C_iterator it = m_listenerList.begin();
	for (; it != m_listenerList.end(); it ++)
	{
		(*it)->DoEvents(s);
	}		
}
